/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.isn.tratamiento.entity;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

import com.isn.atencionemergencia.entity.DetalleResultadooaeMedicamento;

/**
 *
 * @author pool
 */
@Entity
@Table(name = "medicamento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Medicamento.findAll", query = "SELECT m FROM Medicamento m"),
    @NamedQuery(name = "Medicamento.findByCodMedi", query = "SELECT m FROM Medicamento m WHERE m.codMedi = :codMedi"),
    @NamedQuery(name = "Medicamento.findByDescMedi", query = "SELECT m FROM Medicamento m WHERE m.descMedi = :descMedi")})
public class Medicamento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "Cod_Medi", columnDefinition="CHAR(5) unsigned")
    private String codMedi;
    @Column(name = "Desc_Medi")
    private String descMedi;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "medicamento")
    private Collection<DetalleResultadooaeMedicamento> detalleResultadooaeMedicamentoCollection;
    @JoinColumn(name = "Cod_Tipmedi", referencedColumnName = "Cod_Tipmedi")
    @ManyToOne(optional = false)
    private TipoDeMedicamento codTipmedi;

    public Medicamento() {
    }

    public Medicamento(String codMedi) {
        this.codMedi = codMedi;
    }

    public String getCodMedi() {
        return codMedi;
    }

    public void setCodMedi(String codMedi) {
        this.codMedi = codMedi;
    }

    public String getDescMedi() {
        return descMedi;
    }

    public void setDescMedi(String descMedi) {
        this.descMedi = descMedi;
    }

    @XmlTransient
    public Collection<DetalleResultadooaeMedicamento> getDetalleResultadooaeMedicamentoCollection() {
        return detalleResultadooaeMedicamentoCollection;
    }

    public void setDetalleResultadooaeMedicamentoCollection(Collection<DetalleResultadooaeMedicamento> detalleResultadooaeMedicamentoCollection) {
        this.detalleResultadooaeMedicamentoCollection = detalleResultadooaeMedicamentoCollection;
    }

    public TipoDeMedicamento getCodTipmedi() {
        return codTipmedi;
    }

    public void setCodTipmedi(TipoDeMedicamento codTipmedi) {
        this.codTipmedi = codTipmedi;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codMedi != null ? codMedi.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Medicamento)) {
            return false;
        }
        Medicamento other = (Medicamento) object;
        if ((this.codMedi == null && other.codMedi != null) || (this.codMedi != null && !this.codMedi.equals(other.codMedi))) {
            return false;
        }
        return true;
    }
   
}
